package org.example.scenicspot.controller;

import org.example.scenicspot.domain.ScenicSpot;
import org.example.scenicspot.service.scenicSpotService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/")

public class scenicSpotController {
    @Autowired
    private scenicSpotService scenicSpotService;

    @GetMapping("/scenicSpot")
    public List<ScenicSpot> showscenicSpot(){
        return scenicSpotService.showscenicSpot();
    }

    @GetMapping ("/searchscenicSpot")
    public List<ScenicSpot> searchscenicSpot(String keyword){
        return scenicSpotService.searchscenicSpot(keyword);
    }

    @GetMapping ("/searchscenicSpotByID")
    public ScenicSpot searchscenicSpotByID(int id){
        return scenicSpotService.searchscenicSpotbyID(id);
    }

    @GetMapping ("/deletescenicSpot")
    public void deletescenicSpot(int id){
        scenicSpotService.deletescenicSpot(id);
    }

    @PostMapping ("/insertscenicSpot")
    public void insertscenicSpot(@RequestBody ScenicSpot scenicSpot){
        scenicSpotService.insertscenicSpot(scenicSpot);
    }

    @PostMapping ("/updatescenicSpot")
    public void updatescenicSpot(@RequestBody ScenicSpot scenicSpot){
        scenicSpotService.updatescenicSpot(scenicSpot);
    }

    @PostMapping("/updateScore")
    public String updateScore(@RequestBody ScenicSpot scenicSpot){
        scenicSpotService.updateScore(scenicSpot);
        System.out.println(scenicSpot.getScore());
        return "OK";
    }
}
